from common.read_xmind import ReadXmind
from common.test_data import TestData
import copy

test_data = TestData()


class NoOperation:

    def __init__(self, xmind_path, sheet_name):
        self.xmind_data = ReadXmind(path=xmind_path, sheet=sheet_name).processed_data()
        self.result = []

    def generate_case(self, model_data):
        """
        生成用例
        :param model_data: 模块数据
        :return:
        """
        # 直接
        template_data = copy.deepcopy(model_data)
        for i, j in template_data['结果'].items():
            template_data['结果'] = j
            template_data['用例等级'] = "P1"
        self.result.append(template_data)

    def case(self):
        for model in self.xmind_data:
            # 循环模块
            if model['标签'] == '无操作类型':
                self.generate_case(model)
        return self.result


def result(xmind_path, sheet):
    return NoOperation(xmind_path=xmind_path, sheet_name=sheet).case()


if __name__ == '__main__':
    import json

    test = NoOperation(r'D:\Desktop\3.0.0.1雷达.xmind', '画布 2')
    print(json.dumps(test.case(), ensure_ascii=False))
